
# money=0
# def cun_money(num):
#     global money
#     money+=num
#     print(f"成功存进银行{num}元，余额剩余{money}元")
#     return money
# def qu_money(num):
#     global money
#     if money<num:
#         print(f"您的余额不足，余额还剩{money}元")
#     money-=num
#     print(f"您已成功取出{num}元，存款还剩余{money}元")
#     return money
# def check():
#     return print(f"你的余额还剩余{money}元")
# def main():
#     while True:
#         print("欢迎来到简易的银行模拟python语言版本")
#         print("查看余额\t选项1")
#         print("存钱\t\t选项2")
#         print("取钱\t\t选项3")
#         print("退出\t\t选项4")
#         keyboard=int(input("请输入您的操作对应的选项上的数字："))
#         if keyboard==1:
#              check()
#         if keyboard==2:
#             cun_money(money)
#         if keyboard==3:
#             qu_money(money)
#         if keyboard==4:
#             break
# main()


money = 1000


def cun_money(num):
    global money
    money += num
    print(f"成功存进银行{num}元，余额剩余{money}元")
    return money


def qu_money(num):
    global money
    if money < num:
        print(f"您的余额不足，余额还剩{money}元")
        return money  # 如果余额不足，则不应该减少money的值
    money -= num
    print(f"您已成功取出{num}元，存款还剩余{money}元")
    return money


def check():
    print(f"你的余额还剩余{money}元")


def main():
    while True:
        print("欢迎来到简易的银行模拟python语言版本")
        print("查看余额\t选项1")
        print("存钱\t\t选项2")
        print("取钱\t\t选项3")
        print("退出\t\t选项4")
        try:
            keyboard = int(input("请输入您的操作对应的选项上的数字："))
        except ValueError:
            print("输入错误，请输入一个有效的数字选项。")
            continue

        if keyboard == 1:
            check()
        elif keyboard == 2:
            try:
                amount = int(input("请输入您想要存入的金额："))
                if amount < 0:
                    print("存入金额不能为负数，请重新输入。")
                    continue
                cun_money(amount)
            except ValueError:
                print("输入错误，请输入一个有效的数字。")
        elif keyboard == 3:
            try:
                amount = int(input("请输入您想要取出的金额："))
                if amount < 0:
                    print("取出金额不能为负数，请重新输入。")
                    continue
                qu_money(amount)
            except ValueError:
                print("输入错误，请输入一个有效的数字。")
        elif keyboard == 4:
            print("感谢使用我们的服务，再见！")
            break
        else:
            print("没有这个选项，请重新选择。")
main()



